package org.charles.zhifou.manager;

import com.aliyun.oss.OSS;
import jakarta.annotation.Resource;
import org.charles.zhifou.common.config.AliyunOssConfig;
import org.springframework.stereotype.Component;

import java.io.File;

/**
 * <h1>阿里云存储组件</h1>
 *
 * @author charles
 * @version 1.0
 */
@Component
public class AliyunOssManager {

    @Resource
    private AliyunOssConfig ossConfig;

    @Resource
    private OSS ossClient;

    /**
     * 上传文件
     * @param objectName 对象名
     * @param file 文件
     */
    public void putObject(String objectName, File file) {
        ossClient.putObject(ossConfig.getBucketName(), objectName, file);
    }
}
